package clustering;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import preprocess.XMLDoc;
import similarity.Similarity;

/**
 * Just put the xml document into a random cluster
 * 
 * @author huangcd
 * 
 */
public class RandomClustering extends Clustering
{
    public RandomClustering(Similarity similarity)
    {
        super(similarity);
    }

    @Override
    public List<List<XMLDoc>> cluster(List<XMLDoc> list, int count)
    {
        Random rand = new Random(System.currentTimeMillis());
        List<List<XMLDoc>> result = new ArrayList<List<XMLDoc>>();
        for (int i = 0; i < count; i++)
        {
            result.add(new ArrayList<XMLDoc>());
        }
        for (XMLDoc doc : list)
        {
            result.get(rand.nextInt(count)).add(doc);
        }
        return result;
    }
}
